﻿using HuiLian.Common.Input;
using HuiLian.Common.Output;
using HuiLian.Model.Platform;
using HuiLian.Service.Platform.Dma.Input;
using HuiLian.Service.Platform.Dma;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace HuiLian.Web.Controllers.Platform
{
    /// <summary>
    /// 管网运行压力管理
    /// </summary>
    public class DmaController : AreaController
    {
        private readonly IDmaService _dmaServices;

        public DmaController(IDmaService DmaServices)
        {
            _dmaServices = DmaServices;
        }

        /// <summary>
        /// 查询单条管网运行压力
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _dmaServices.GetAsync(id);
        }

        /// <summary>
        /// 查询全部管网运行压力
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetList(string key)
        {
            return await _dmaServices.ListAsync(key);
        }

        /// <summary>
        /// 查询分页管网运行压力
        /// </summary>
        /// <param name="model">分页模型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<DmaEntity> model)
        {
            return await _dmaServices.PageAsync(model);
        }

        /// <summary>
        /// 新增管网运行压力
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(DmaAddInput input)
        {
            return await _dmaServices.AddAsync(input);
        }

        /// <summary>
        /// 修改管网运行压力
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(DmaUpdateInput input)
        {
            return await _dmaServices.UpdateAsync(input);
        }

        /// <summary>
        /// 删除管网运行压力
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _dmaServices.SoftDeleteAsync(id);
        }

        /// <summary>
        /// 批量删除管网运行压力
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> BatchSoftDelete(long[] ids)
        {
            return await _dmaServices.BatchSoftDeleteAsync(ids);
        }
    }
}
